package com.hawthorn.dic.controller;


import com.hawthorn.dic.service.SysDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>todo 系统字典controller</p>
 * @author: andyten@tom.com | xukaixing@hotmail.com
 * @created: 2021/12/1 9:16 AM
 * @version v1.0.1
 * @copyright: Copyright (c)  andyten
 */
@Api(tags = {"dic-sysdict"})
@RestController
@RequestMapping("/sysdict/")
@Slf4j
public class SysDictController
{
  @Resource
  SysDictService sysDictService;

  /**
   * <p>todo 生成字典</p>
   * @author: andyten@tom.com
   * @date: 2021/12/9 4:36 PM
   * @version: 1.0.1
   */
  @ApiOperation(value = "查询->生成字典", notes = "查询->生成字典")
  @ApiImplicitParams({
  })
  @GetMapping(value = "/findDict")
  public String findDict()
  {
    String res = sysDictService.findDict();
    // log.info("====== dicts ======" + res);
    return res;
  }

  /**
   * <p>todo 生成字典行政区划</p>
   * @author: andyten@tom.com
   * @date: 2021/12/9 4:36 PM
   * @version: 1.0.1
   */
  @ApiOperation(value = "查询->生成字典行政区划", notes = "查询->生成行政区划")
  @ApiImplicitParams({
  })
  @GetMapping(value = "/findDictDivision")
  public String findDictDivision()
  {
    String res = sysDictService.findDictDivision();
    // log.info("====== divisions ======" + res);
    return res;
  }

  @GetMapping(value = "/findDictFromTable")
  public String findDictFromTable(@RequestParam String vparam, @RequestParam String query)
  {
    String res = sysDictService.findDictFromTable(vparam, query);
    // log.info("====== tabledicts ======" + res);
    return res;
  }

}
